package com.nursing.controller.nurse;

import com.nursing.bean.CarePlan;
import com.nursing.model.Result;
import com.nursing.model.vo.admin.BindTaskVo;
import com.nursing.model.vo.admin.CreatePlan;
import com.nursing.service.NurseService;
import com.nursing.service.PlanService;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@RestController
@RequestMapping("/nurse")
public class NurseCarePlan {
    private final NurseService service;
    private final PlanService planService;

    public NurseCarePlan(NurseService service, PlanService planService) {
        this.service = service;
        this.planService = planService;
    }

    @PostMapping("/createPlan")
    public Result<String> add(@RequestBody CreatePlan createPlan) {
        CarePlan carePlan = new CarePlan();
        carePlan.setElderId(createPlan.getElderId());
        carePlan.setPlanDetails(createPlan.getPlanDetails());
        carePlan.setCreatedAt(LocalDateTime.now());
        planService.addPlan(carePlan);
        return Result.success("添加成功");
    }



    @PostMapping("/bindTask")
    public void bindTask(@RequestBody BindTaskVo bindTaskVo) {
        service.bindTask(bindTaskVo.getNurseId(), bindTaskVo.getPlanId(), bindTaskVo.getTaskDetails());
    }
}
